﻿/*
 * LdResponse
 * 
 * initial implementation : 26.6.2013
 *
 * Copyright (c) Adam Sida, asida@centrum.cz.
 * All rights reserved.
 * 
 * for license see cz.uhul.DSMLv2.txt
 */
using System;
using System.Xml.Serialization;


namespace cz.uhul.DSMLv2
{




  /// <summary>
  /// The LdResponse abstract class is the base
  /// class for request response classes, like the LdSearchResponse
  /// and LdAddResponse classes.
  /// </summary>
  public abstract class LdResponse : LdOperation
  {



    public LdResponse()
      :base()
    {}




    public LdResponse(LdResultCodeEnum code, string description, string errMsg)
      :this()
    {
      this.ResultCode = new LdResultCode()
      {
        Code = code
        ,Description = description
      };
      ErrorMessage = errMsg;
    }





    /// <summary>
    /// The LDResponse.ResultCode property
    /// contains the result code of the operation.
    /// </summary>
    [XmlElement(ElementName = "resultCode", IsNullable = false, Order=0)]
    public virtual LdResultCode ResultCode { get; set; }
    
    
    
    
    
    
    /// <summary>
    /// The System.DirectoryServices.Protocols.DirectoryResponse.ErrorMessage
    /// property contains the error message, if any, for this operation.
    /// </summary>
    [XmlElement(ElementName = "errorMessage", IsNullable = true, Order=1)]
    public virtual string ErrorMessage { get; set; }






    /// <summary>
    /// The LdResponse.MatchedDN property 
    /// contains the matched distinguished name returned by the server.
    /// </summary>
    [XmlAttributeAttribute(AttributeName = "matchedDN")]
    public virtual string MatchedDN { get; set; }






    /// <summary>
    /// The LdResponse.Referral
    /// property contains the server referrals.
    /// </summary>
    [XmlIgnore]
    public virtual Uri[] Referral { get; set; }





    public bool ShouldSerializeErrorMessage()
    {
      return ErrorMessage != null;
    }




  }

}